#define _CRT_SECURE_NO_WARNINGS 1
//typedef struct People {
//    char mail[20];
//    int score;
//}Peo[10000];

#include<stdio.h>
#include<stdlib.h>
typedef struct People {
    char mail[20];
    int score;
}Peo;
Peo p[10000];
int cmp(Peo* p1, Peo* p2)
{
    if ((p1->score - p2->score) < 0) return -1;
    else if ((p1->score - p2->score) > 0) return 1;
    else {
        if ((p1->mail - p2->mail) < 0) return -1;
        else if ((p1->mail - p2->mail) > 0) return 1;
        else return 0;
    }
}
int main()
{
    int N = 0;
    int G = 0;
    int K = 0;
    int i = 0;
    int money = 0;
    scanf("%d %d %d", &N, &G, &K);
    for (i = 0; i < N; i++)
    {
        scanf("%s %d", &p[i].mail, &p[i].score);
        if (p->score >= G && p->score <= 100)
        {
            money += 50;
        }
        else if (p->score < G && p->score >= 60)
        {
            money += 20;
        }
    }
    qsort(p, N, sizeof(p[0]), cmp);
        for (i = 0; i < K; i++)
        {
            printf("%s %d\n", p[i].mail, p[i].score);
        }
    return 0;
}